﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utility.Models;
using Utility;
namespace JYJJ.Web.Pages
{
    public partial class info : System.Web.UI.Page
    {
        protected string strPayType = ParamsOfRequest.Request("PayType");
        protected string strAmount = ParamsOfRequest.Request("amount");
        protected string strCount = ParamsOfRequest.Request("count");
        protected string strChoice = ParamsOfRequest.Request("Choice");
        protected string strDonateId = ParamsOfRequest.Request("donateId");
        protected string orderId = ParamsOfRequest.Request("orderId");
        protected void Page_Load(object sender, EventArgs e)
        {
            donateId.Value = strDonateId;
            PayType.Value = strPayType;
            amount.Value = strAmount;
            count.Value = strCount;
            Choice.Value = strChoice;

            model_Donate model = JYJJ.BLL.ServceHelper.ServiceDonate().GetDonateModel(donateId.Value.ToSafeInt());
            if (model != null)
            {
                imgUrl.ImageUrl = Utility.Config.ConfigHelper.WebHomeAddress_CMS + "" + model.ImageUrl.Replace("@", "");
                ltDesc.Text = model.Abstract;
                ltTitle.Text = model.Title;
                if (strChoice == "0")
                {
                    ltAmount.Text = "￥ " + strAmount + "元";
                }
                else if (strChoice == "1")
                {
                    ltAmount.Text = "￥ " + ((strCount).ToSafeDecimal() * 1).ToSafeString() + "元";
                }
                else if (strChoice == "100")
                {
                    ltAmount.Text = "￥ " + ((strCount).ToSafeDecimal() * 100).ToSafeString() + "元";
                }

                if (!orderId.IsNullOrEmpty())
                {
                    model_Donate_Order order = JYJJ.BLL.ServceHelper.ServiceDonate().GetDonateOrderModelByOrderID(orderId);
                    if (order != null)
                    {
                        #region 设置订单数据
                        donateId.Value = strDonateId;
                        PayType.Value = order.way.ToSafeString();
                        amount.Value = order.amount.ToSafeString();
                        count.Value = order.num.ToSafeString();
                        Choice.Value = order.choice.ToSafeString();

                        if (Choice.Value == "0")
                        {
                            ltAmount.Text = "￥ " + amount.Value + "元";
                        }
                        else if (Choice.Value == "1")
                        {
                            ltAmount.Text = "￥ " + ((amount.Value).ToSafeDecimal() * 1).ToSafeString() + "元";
                        }
                        else if (Choice.Value == "100")
                        {
                            ltAmount.Text = "￥ " + ((amount.Value).ToSafeDecimal() * 100).ToSafeString() + "元";
                        }

                        province.Value = order.province;
                        city.Value = order.city;
                        district.Value = order.district;
                        email.Value = order.email;
                        phone.Value = order.phone;
                        if (order.needInvoice.ToSafeBool())
                        {
                            rdo_sj_1.Checked = true;
                            rdo_sj_0.Checked = false;
                        }
                        else
                        {
                            rdo_sj_1.Checked = false;
                            rdo_sj_0.Checked = true;
                        }
                        name.Value = order.name;
                        if (order.gender.ToSafeInt() == 1)
                        {
                            rdo_sex_1.Checked = true;
                            rdo_sex_2.Checked = false;
                        }
                        else
                        {
                            rdo_sex_1.Checked = false;
                            rdo_sex_2.Checked = true;
                        }
                        if (order.UserId == 0)
                        {
                            niming.Checked = true;
                        }
                        else
                        {
                            niming.Checked = false;
                        }
                        Address.Value = order.Address;
                        zipCode.Value = order.zipCode;
                        if (order.IsAlumni.ToSafeBool())
                        {
                            rdp_xy_1.Checked = true;
                            rdp_xy_0.Checked = false;
                        }
                        else
                        {
                            rdp_xy_1.Checked = false;
                            rdp_xy_0.Checked = true;
                        }
                        #endregion
                    }
                }
            }
            else
            {
                divButton.Visible = false;

                string script = " alert('提示：数据传输有误，请核对');   window.location.href='detail.aspx?id=" + donateId + "';";
                HttpContext.Current.Response.Write("<script language=\"javascript\" type=\"text/javascript\" defer>\n" + script + "\n</script>\n");
                HttpContext.Current.Response.End();
            }
        }
    }
}